package epoch.game.core.stat;

/**
 * 执行信息统计 生产环境中不建议开启，会影响系统性能。
 */

public class StatisticsService {

	private static final long SIZE_MS = 1_000_000L;

	private static final long SIZE_S = 1_000_000_000L;

	public static void printResult() {
		// StatisticsOB.showResult();
		StatisticsMSG.showResult();
		StatisticsRPC.showResult();
		StatisticsHandler.showResult();
	}
	
	public static void clearStatData(){
		StatisticsMSG.clearData();
		StatisticsRPC.clearData();
		StatisticsHandler.clearData();
	}

	/**
	 * 格式化纳秒显示
	 * 
	 * @return
	 */
	public static String formatTime(long nano) {
		return nano > 5 * SIZE_S ? (nano / SIZE_S + "s") : (nano > 10 * SIZE_MS ? (nano / SIZE_MS + "ms") : (String.format("%.2f", 1.0 * nano / SIZE_MS) + "ms"));
	}

}
